package com.charonmc.utils.bookutils;

import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;

public class CustomBookOpenEvent extends Event implements Cancellable
{
    private static final HandlerList handlers = new HandlerList();
    private final Player player;
    private final Hand hand;
    private final ItemStack book;
    private boolean cancelled;

    public CustomBookOpenEvent(Player player, ItemStack book, boolean offHand) {
        this.player = player;
        this.book = book;
        this.hand = offHand ? Hand.OFF_HAND : Hand.MAIN_HAND;
    }

    public static HandlerList getHandlerList() {
        return handlers;
    }

    public HandlerList getHandlers() {
        return handlers;
    }

    public Player getPlayer() {
        return this.player;
    }

    public Hand getHand() {
        return this.hand;
    }

    public ItemStack getBook() {
        return this.book;
    }

    public boolean isCancelled() {
        return this.cancelled;
    }

    public void setCancelled(boolean cancelled) {
        this.cancelled = cancelled;
    }

    public static enum Hand {
        MAIN_HAND,
        OFF_HAND;

        private Hand() {
        }
    }
}
